/*
 * @Description:全局组件
 * @Autor: dengyongliang
 * @Date: 2021-04-17 10:04:50
 * @LastEditors: dengyongliang
 * @LastEditTime: 2021-08-16 13:33:04
 */

/**
 * @description: 全局loading
 * @param {String} msg
 * @param {object | string} el
 * @return {*}
 * @author: dengyongliang
 */
export function siLoading(msg, el) {
  return this.$loading({
    target: el,
    lock: true,
    text: msg || '',
    background: 'rgba(0,0,0, 0.1)'
  })
}

/**
 * @description: 全局confirm
 * @param {String} msg
 * @return {*}
 * @author: dengyongliang
 */
export function siConfirm(msg) {
  msg = msg || '确认消息'
  return new Promise((resolve, reject) => {
    this.$confirm(msg + '', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
      .then(res => {
        this.$siLoading()
        resolve(res)
      })
      .catch(err => {
        reject(err)
      })
  })
}
